package com.sinosoft.hydra.um.domain.model;

import org.apache.commons.lang.StringUtils;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.List;

/**
 * Created by Administrator on 2016/6/29.
 */
@XmlRootElement(name = "config")
public class ImportConfig implements Serializable {

    private String title;

    private List<Column> columns;

    private String filePath;

    public String getFilePath() {
        return filePath;
    }

    public String getFileEndStr() {
        if(StringUtils.isBlank(filePath)){
            return "";
        }
        int i = filePath.lastIndexOf(".");
        return i == -1 ? "" : filePath.substring(i + 1);
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @XmlElementWrapper(name = "columns")
    @XmlElement(name = "column")
    public List<Column> getColumns() {
        return columns;
    }

    public void setColumns(List<Column> columns) {
        this.columns = columns;
    }

    public static class Column implements Serializable {
        private String title;
        private String description;
        private String warn;

        public String getTitle() {
            return title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public String getDescription() {
            return description;
        }

        public void setDescription(String description) {
            this.description = description;
        }

        public String getWarn() {
            return warn;
        }

        public void setWarn(String warn) {
            this.warn = warn;
        }
    }
}
